package com.ymttest.database.sqlwapper;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.couponvirtualrecord;

import com.ymttest.database.model.coupon;
import com.ymttest.utils.EnvSetup;

public class couponvirtualrecordWapper {
	SqlManager manager;

    public couponvirtualrecordWapper() {
        manager = new SqlManager("mysqlcoupon" + EnvSetup.getEnv());
    }
    /**
     * 获取需要核销的虚拟券-已经使用未核销
     * @return
     */
    public List<couponvirtualrecord> getNeedCancelVirtualCoupon()
    {
     List<couponvirtualrecord> result = manager
             .getSelectResults(
                     "com.ymttest.database.mapping.couponvirtualrecordMapper.getNeedCancelVirtualCoupon",
                     null);
     manager.commit();
     return result;
    }
    /**
     * 获取需要核销的虚拟券-已经使用,已经核销
     * @return
     */
    public List<couponvirtualrecord> getCancelFlag()
    {
     List<couponvirtualrecord> result = manager
             .getSelectResults(
                     "com.ymttest.database.mapping.couponvirtualrecordMapper.getCancelFlag",
                     null);
     manager.commit();
     return result;
    }
    
    public List<couponvirtualrecord> selectTop3couponvirtualrecord()
    {
     List<couponvirtualrecord> result = manager
             .getSelectResults(
                     "com.ymttest.database.mapping.couponvirtualrecordMapper.selectTop3couponvirtualrecord",
                     null);
     manager.commit();
     return result;
    }
    public int updateByPrimaryKey(couponvirtualrecord record)
    {
     int result=manager
             .update(
                     "com.ymttest.database.mapping.couponvirtualrecordMapper.updateByPrimaryKey",
                     record);
     manager.commit();
     return result;
    }
    
    public int updateByIsUsedIsCancel(boolean  IsUsed,boolean IsCancel,Integer RecordId) 
    {
       	 Map m = new HashMap();
   	    m.put("IsUsed", IsUsed);
   	    m.put("IsCancel", IsCancel);
   	    m.put("RecordId", RecordId);
        int result=manager
                .update(
                        "com.ymttest.database.mapping.couponvirtualrecordMapper.updateByIsUsedIsCancel",
                        m);
        manager.commit();
        return result;
    }
    
    
    public List<couponvirtualrecord> selectcouponvirtualrecordByCouponCodeAndVirtualCouponCode(String couponCode,String virtualCode) {
    	 Map m = new HashMap();
	        m.put("couponCode", couponCode);
	        m.put("virtualCode", virtualCode);
        List<couponvirtualrecord> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.couponvirtualrecordMapper.selectcouponvirtualrecordByCouponCodeAndVirtualCouponCode",
                        m);
        manager.commit();
        return result;
    }

    public List<couponvirtualrecord> selectTop1couponvirtualrecord() {
    	List<couponvirtualrecord> result =  manager
               .getSelectResults(
                       "com.ymttest.database.mapping.couponvirtualrecordMapper.selectTop1couponvirtualrecord",
                       null);
       manager.commit();
       return result;
   }
    public List<couponvirtualrecord> selectcouponVirtualRelationsByCouponCodeAndVirtualCouponCode(String couponCode,String virtualCode) {
   	 Map m = new HashMap();
	        m.put("couponCode", couponCode);
	        m.put("virtualCode", virtualCode);
       List<couponvirtualrecord> result = manager
               .getSelectResults(
                       "com.ymttest.database.mapping.couponvirtualrecordMapper.selectcouponVirtualRelationsByCouponCodeAndVirtualCouponCode",
                       m);
       manager.commit();
       return result;
   }
    

    public static void main(String[] args) {
    	couponvirtualrecordWapper test = new couponvirtualrecordWapper();

        System.out.println(test.selectTop1couponvirtualrecord());
        // test.insertYmtCouponSetting(3,11);
        // Logger.debug(test.getLastYmtCouponSettingId());


    }
}
